package com.demo3;

import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class utils {
    protected static String pb(String str, byte[] bArr) {
        Throwable th;
        Exception e;
        HttpURLConnection httpURLConne;
        BufferedReader bufferedReader = null;
        try {
            try {
                httpURLConne = (HttpURLConnection) new URL(str).openConnection();
                try {
                    httpURLConne.setRequestProperty("Content-type", "application/octet-stream");
                    httpURLConne.setRequestMethod("POST");
                    httpURLConne.setDoOutput(true);
                    httpURLConne.setConnectTimeout(0x2710);
                    httpURLConne.setReadTimeout(0x2710);
                    DataOutputStream dataOutputStream = new DataOutputStream(httpURLConne.getOutputStream());
                    dataOutputStream.write(bArr);
                    dataOutputStream.flush();
                    dataOutputStream.close();
                    int responseCode = httpURLConne.getResponseCode();
                    if (responseCode != 200) {
                        return "";
                    }
                    BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(httpURLConne.getInputStream()));
                    try {
                        StringBuilder sb = new StringBuilder();
                        while (true) {
                            String readLine = bufferedReader2.readLine();
                            if (readLine == null) {
                                break;
                            }
                            sb.append(readLine);
                        }
                        JSONObject jSONObject = new JSONObject(sb.toString());
                        int i = jSONObject.getInt("code");
                        if (i != 200) {
                            return "";
                        }
                        String string = jSONObject.getString("data");
                        if (string.length() > 40 && !string.startsWith("{\"")) {
                            try {
                                bufferedReader2.close();
                            } catch (IOException e3) {

                            }
                            return string;
                        }

                        try {
                            bufferedReader2.close();
                        } catch (IOException e4) {
                            e4.printStackTrace();
                        }
                        return "";
                    } catch (Exception e5) {
                        return "";
                    } catch (Throwable th2) {
                        throw th2;
                    }
                } catch (Exception e8) {
                    e = e8;
                }
            } catch (Throwable th3) {
                th = th3;
            }
        } catch (Exception e9) {
            e = e9;
            return "";
        } catch (Throwable th4) {
            th = th4;
            return "";
        }
        return "";
    };
}
